home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77666_nicinterface_prop.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  11.7 KB  |  367 lines

  1. <%@ Language=VBScript   %>
  2. <%    Option Explicit     %>
  3. <%
  4.     '-------------------------------------------------------------------------
  5.     ' nicinterface_prop.asp: Serve the NIC Configuration Object Task Selector
  6.     '
  7.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  8.     '
  9.     ' Date        Description
  10.     '28-Feb-01    Creation date
  11.     '13-Mar-01  Modified date
  12.     '-------------------------------------------------------------------------
  13.  
  14. %>
  15.     <!-- #include virtual="/admin/inc_framework.asp" -->
  16.     <!-- #include virtual="/admin/ots_main.asp" -->
  17.     <!-- #include file="loc_nicspecific.asp" -->
  18.     <!-- #include file="inc_network.asp" -->
  19. <%
  20.     
  21.     '-------------------------------------------------------------------------
  22.     ' Global Constants
  23.     '-------------------------------------------------------------------------
  24.     Const NIC_DIM                            = 6
  25.     Const NIC_ID                            = 0
  26.     Const NIC_DESC                            = 1
  27.     Const NIC_NAME                            = 2
  28.     Const NIC_IPADDRESS                        = 3
  29.     Const NIC_DHCP_ENABLED                    = 4
  30.     CONST NIC_SETTINGID                        = 5
  31.     Const NICCARDS_PER_PAGE                    = 19  'holds max not cards that can 
  32.                                                   'displayed on to the OTS                
  33.     
  34.     '-------------------------------------------------------------------------
  35.     ' Global Variables
  36.     '-------------------------------------------------------------------------
  37.     Dim rc                                ' to hold return code for page
  38.     Dim page                            ' to hold page object
  39.     Dim g_bSortRequested
  40.     Dim g_iSortCol
  41.     Dim g_sSortSequence
  42.     Dim g_AppTalkInstalled                ' whether appletalk protocol is installed
  43.     
  44.     Dim SOURCE_FILE    
  45.     SOURCE_FILE = SA_GetScriptFileName()    
  46.         
  47.     '======================================================
  48.     ' Entry point
  49.     '======================================================
  50.  
  51.     ' Create Page
  52.     call SA_CreatePage(L_NIC_OTS_PAGE_TITLE, "", PT_AREA, page )
  53.  
  54.     ' Show page
  55.     call SA_ShowPage( page )
  56.  
  57.     
  58.     '======================================================
  59.     ' Web Framework Event Handlers
  60.     '======================================================
  61.     
  62.     '---------------------------------------------------------------------
  63.     ' Function name:    OnInitPage
  64.     ' Description:        Called to signal first time processing for this page. 
  65.     ' Input Variables:    PageIn and EventArg
  66.     ' Output Variables:    PageIn, EventArg
  67.     ' Return Values:    TRUE to indicate initialization was successful. FALSE to indicate
  68.     '                    errors. Returning FALSE will cause the page to be abandoned.
  69.     ' Global Variables: None
  70.     ' Called to signal first time processing for this page. Use this method
  71.     ' to do first time initialization tasks. 
  72.     '---------------------------------------------------------------------
  73.  
  74.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  75.         
  76.         Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  77.         
  78.         ' Sort first column in ascending sequence
  79.         g_iSortCol = 0
  80.         g_sSortSequence = "A"
  81.     
  82.     End Function
  83.  
  84.     '---------------------------------------------------------------------
  85.     ' Function name:    OnServeAreaPage
  86.     ' Description:        Called when the page needs to be served. 
  87.     ' Input Variables:    PageIn, EventArg
  88.     ' Output Variables:    PageIn, EventArg
  89.     ' Return Values:    TRUE to indicate no problems occured. FALSE to indicate errors.
  90.     '                    Returning FALSE will cause the page to be abandoned.
  91.     ' Global Variables: In:L_(*)-Localization Strings
  92.     ' Called when the page needs to be served. Use this method to serve content.
  93.     '---------------------------------------------------------------------
  94.     
  95.     Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  96.         
  97.         Err.Clear
  98.         on error resume next
  99.         
  100.         Dim table                'to hold table object
  101.         Dim colFlags            'to hold flag value
  102.         Dim nCount                 'to hold count for the loop of NIC collection
  103.         Dim count                'to hold count for the loop of NIC collection
  104.         Dim cardCount            'to hold card count
  105.         Dim cards                'to hold Collection of NIC cards
  106.         Dim Connectionstatus    'to hold Connection status of NIC Card
  107.         Dim objConnStatus
  108.         
  109.         set objConnStatus = server.CreateObject("MediaStatus.MediaState")
  110.         if Err.number <> 0 then
  111.             SA_ServeFailurePage L_UNABLETOCREATEOBJECT_ERRORMESSAGE
  112.             exit function
  113.         end if
  114.         
  115.         Call SA_TraceOut(SOURCE_FILE, "OnServeAreaPage")
  116.         
  117.         ' Create the table
  118.         table = OTS_CreateTable("","")
  119.  
  120.         ' Create columns and add them to the table            
  121.         
  122.         'Add hidden column for AdapterID        
  123.         colFlags = (OTS_COL_FLAG_HIDDEN OR OTS_COL_KEY)
  124.                     
  125.         Call OTS_AddTableColumn(table, OTS_CreateColumn( L_ADAPTERID_TEXT, "left",colFlags))
  126.  
  127.         'Column containing Description value for each NIC Card
  128.         colFlags = OTS_COL_SORT
  129.         Call OTS_AddTableColumn(table, OTS_CreateColumnEx( L_NIC_OTS_COLUMN_NAME, "left",colFlags,20))
  130.  
  131.         
  132.         'Column containing Type value for each NIC Card
  133.         colFlags = OTS_COL_SORT
  134.         Call OTS_AddTableColumn(table, OTS_CreateColumnEx( L_NIC_OTS_COLUMN_TYPE, "left",colFlags,20))
  135.         
  136.  
  137.         'Column containing IP value for each NIC Card
  138.         colFlags = OTS_COL_SORT
  139.         Call OTS_AddTableColumn(table, OTS_CreateColumnEx( L_NIC_OTS_COLUMN_IPADDRESS,"left", colFlags,15))
  140.         
  141.  
  142.         'Column containing Configuration for each NIC Card
  143.         colFlags = OTS_COL_SORT
  144.         Call OTS_AddTableColumn(table, OTS_CreateColumnEx( L_NIC_OTS_COLUMN_CURRENT_CONFIG, "left", colFlags,6))
  145.         
  146.  
  147.         'Column containing Status for each NIC Card
  148.         colFlags = OTS_COL_SORT
  149.         Call OTS_AddTableColumn(table, OTS_CreateColumnEx( L_STATUS_TEXT, "left", colFlags,12))
  150.         
  151.         'Get the NICCardCollection
  152.         cardCount = GetNICCardCollection(cards)
  153.             
  154.         'Navigation logic
  155.  
  156.         For count = 0 to (cardCount - 1)
  157.  
  158.             Dim nicCard
  159.             Dim strTCPIPConfigStatus
  160.                 
  161.             nicCard = cards(count)
  162.  
  163.             If ( nicCard(NIC_DHCP_ENABLED) ) Then
  164.                 strTCPIPConfigStatus = L_NIC_OTS_CONFIG_DHCP
  165.             Else
  166.                 strTCPIPConfigStatus = L_NIC_OTS_CONFIG_MANUAL
  167.             End If
  168.  
  169.             if objConnStatus.IsConnected(nicCard(NIC_SETTINGID)) then
  170.                 Connectionstatus =  L_CONNECTED_TEXT
  171.             else
  172.                 Connectionstatus =  L_DISCONNECTED_TEXT
  173.             end if
  174.                             
  175.             nCount = nCount + 1
  176.             
  177.             ' select the rows
  178.             Call OTS_AddTableRow( table, Array(nicCard(NIC_ID), nicCard(NIC_NAME), nicCard(NIC_DESC), nicCard(NIC_IPADDRESS),strTCPIPConfigStatus,Connectionstatus))
  179.                         
  180.             if Count = NICCARDS_PER_PAGE then Exit For            
  181.             
  182.         Next        
  183.         
  184.         
  185.         'Add Task title
  186.         Call OTS_SetTableTasksTitle(table, L_NIC_OTS_TASK_TITLE)
  187.  
  188.         'Add Rename Task
  189.         Call OTS_AddTableTask( table, OTS_CreateTask(L_NIC_OTS_TASK_RENAME, _
  190.                                         L_NIC_OTS_TASK_RENAME_DESC, _
  191.                                         "Network/nicRename_prop.asp",_
  192.                                         OTS_PT_PROPERTY) )
  193.         'Add IP Task
  194.         Call OTS_AddTableTask( table, OTS_CreateTask(L_NIC_OTS_TASK_IP, _
  195.                                         L_NIC_OTS_TASK_IP_DESC, _
  196.                                         "Network/nicip_prop.asp",_
  197.                                         OTS_PT_TABBED_PROPERTY) )        
  198.  
  199.         'Add DNS task
  200.         Call OTS_AddTableTask( table, OTS_CreateTask(L_NIC_OTS_TASK_DNS, _
  201.                                         L_NIC_OTS_TASK_DNS_DESC, _
  202.                                         "Network/nicdns_prop.asp",_
  203.                                         OTS_PT_PROPERTY) )
  204.     
  205.         'Add WINS task                                
  206.         Call OTS_AddTableTask( table, OTS_CreateTask(L_NIC_OTS_TASK_WINS, _
  207.                                         L_NIC_OTS_TASK_WINS_DESC, _
  208.                                         "Network/nicwins_prop.asp",_
  209.                                         OTS_PT_PROPERTY) )
  210.             
  211.         'Add AppleTalk task if appletalk protocol is installed
  212.         if g_AppTalkInstalled = true then
  213.             Call OTS_AddTableTask( table, OTS_CreateTask(L_NIC_OTS_TASK_APPLETALK, _
  214.                                             L_NIC_OTS_TASK_APPLETALK_DESC, _
  215.                                             "Network/nicappletalk_prop.asp",_
  216.                                             OTS_PT_PROPERTY) )
  217.         end if
  218.                                 
  219.         ' Enable paging feature
  220.         Call OTS_EnablePaging(table, FALSE)
  221.         
  222.         
  223.         ' Enable sorting 
  224.         Call OTS_SortTable(table, g_iSortCol, g_sSortSequence, SA_RESERVED)
  225.         
  226.         ' Send table to the response stream
  227.         Call OTS_ServeTable(table)
  228.         
  229.         OnServeAreaPage = TRUE
  230.         
  231.         'Release the objects
  232.         set objConnStatus = nothing
  233.         
  234.     End Function
  235.  
  236.     
  237.     '---------------------------------------------------------------------
  238.     ' Function:    OnSortNotify()
  239.     '
  240.     ' Synopsis:    Sorting notification event handler. This event is triggered in one of
  241.     '            the following scenarios:
  242.     '
  243.     '            1) The user presses the search Go button.
  244.     '            2) The user presses either the page next or page previous buttons
  245.     '            3) The user requests a table column sort
  246.     '
  247.     '            The EventArg indicates the source of this notification event which can
  248.     '            be either a sorting change event (scenario 1) or a post back event 
  249.     '            (scenarios 2 or 3)
  250.     '
  251.     '            The sortCol argument indicated which column the user would like to sort
  252.     '            and the sortSeq argument indicates the desired sort sequence which can
  253.     '            be either ascending or descending.
  254.     '
  255.     ' Returns:    Always returns TRUE
  256.     '
  257.     '---------------------------------------------------------------------
  258.     Public Function OnSortNotify(ByRef PageIn, _
  259.                                         ByRef EventArg, _
  260.                                         ByVal sortCol, _
  261.                                         ByVal sortSeq )
  262.             OnSortNotify = TRUE
  263.             
  264.             '
  265.             ' User pressed column sort
  266.             '
  267.             If SA_IsChangeEvent(EventArg) Then
  268.                 Call SA_TraceOut("nicinterface_prop", "OnSortNotify() Change Event Fired")
  269.                 g_iSortCol = sortCol
  270.                 g_sSortSequence = sortSeq
  271.                 g_bSortRequested = TRUE
  272.             '
  273.             ' User presed the search GO button OR clicked either the page next or page prev button
  274.             ElseIf SA_IsPostBackEvent(EventArg) Then
  275.                 Call SA_TraceOut("nicinterface_prop", "OnSortNotify() Postback Event Fired")
  276.                 g_iSortCol = sortCol
  277.                 g_sSortSequence = sortSeq
  278.                 g_bSortRequested = TRUE
  279.             '
  280.             ' Unknown event source
  281.             Else
  282.                 Call SA_TraceOut("nicinterface_prop", "Unrecognized Event in OnSearchNotify()")
  283.             End IF
  284.             
  285.     End Function
  286.  
  287.     '-------------------------------------------------------------------------
  288.     'Function:                GetNICCardCollection
  289.     'Description:            Get Array of IP Enabled NIC Cards for this System
  290.     'Input Variables:        NICCardCollectionOut Array to receive list of NIC Cards
  291.     'Output Variables:        NICCardCollectionOut
  292.     'Returns:                Collection of NIC cards
  293.     'Global Variables:        None
  294.     '-------------------------------------------------------------------------
  295.     Function GetNICCardCollection(ByRef NICCardCollectionOut)
  296.         Err.clear
  297.         On Error Resume Next    
  298.  
  299.         Dim nicCardCollection()        'hold NIC collection
  300.         Dim objService                'hold connection object
  301.         Dim objNICCollection        'hold NIC collection
  302.         Dim objNICConfig            'holds NIC config object
  303.         Dim nicCardCount            'holds NIC card count
  304.         Dim objAppTalk                'hold appletalk object
  305.         
  306.         g_AppTalkInstalled = False
  307.         
  308.         Call SA_TraceOut(SOURCE_FILE, "GetNICCardCollection")
  309.         
  310.         Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  311.         
  312.         Set objNICCollection = objService.ExecQuery("SELECT * from Win32_NetworkAdapterConfiguration where IPEnabled=True")
  313.  
  314.         nicCardCount = 0
  315.         For each objNICConfig in objNICCollection
  316.             Dim nicCard
  317.             Dim aIPAddress
  318.  
  319.             ReDim nicCard(NIC_DIM)
  320.  
  321.             nicCard(NIC_NAME) = GetNicName(objNICConfig.Index)    
  322.  
  323.             'checking for the nullname and discarding
  324.             if  nicCard(NIC_NAME) <> ""  Then
  325.  
  326.                 nicCard(NIC_ID) = objNICConfig.Index
  327.                 nicCard(NIC_DESC) = objNICConfig.Description
  328.                 
  329.                 
  330.                 nicCard(NIC_DHCP_ENABLED) = objNICConfig.DHCPEnabled
  331.                 aIPAddress = objNICConfig.IPAddress
  332.                 If IsArray( aIPAddress ) Then
  333.                     nicCard(NIC_IPADDRESS) = aIPAddress(0)
  334.                 Else
  335.                     nicCard(NIC_IPADDRESS) = aIPAddress
  336.                 End If
  337.                 
  338.                 nicCard(NIC_SETTINGID) = objNICConfig.SettingID
  339.     
  340.                 nicCardCount = nicCardCount + 1
  341.                 ReDim Preserve nicCardCollection(nicCardCount)
  342.                 nicCardCollection(nicCardCount-1) = nicCard
  343.             End IF
  344.  
  345.         Next
  346.  
  347.         If ( nicCardCount > 0 ) Then
  348.             NICCardCollectionOut = nicCardCollection
  349.         End If
  350.  
  351.         GetNICCardCollection = nicCardCount
  352.         
  353.         'Check whether Appletalk protocol is installed or not
  354.         set objAppTalk = objService.Get("Win32_NetworkProtocol.Name='MSAFD AppleTalk [PAP]'")
  355.  
  356.         if isobject(objAppTalk) then
  357.             g_AppTalkInstalled = true
  358.         end if
  359.         
  360.         'Release the objects
  361.         set objService = nothing
  362.         set objNICCollection = nothing
  363.         set objAppTalk = nothing
  364.         
  365.     End Function
  366. %>
  367.